<!--
 * @Author: chenwei
 * @Date: 2022-02-17 17:07:54
 * @LastEditors: chenwei
 * @LastEditTime: 2022-02-25 11:54:01
 * @FilePath: \React\react-demo\0.html
 * @Description: 
 * 
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>

    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <script
      crossorigin
      src="https://unpkg.com/react@16/umd/react.development.js"
    ></script>
    <script
      crossorigin
      src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
    ></script>
    <script type="text/babel">
      // const element = <h1>This is h1</h1>;
      // ReactDOM.render(element, document.getElementById("root"));

      class SelectFrom extends React.Component {
        constructor(props) {
          super(props);

          this.state = {
            value: "",
          };

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);
        }

        handleChange(event) {
          this.setState({
            value: event.target.value,
          });
        }

        handleSubmit(event) {
          console.log("this is submit", this.state.value);
          event.preventDefault();
        }

        render() {
          return (
            <form onSubmit={this.handleSubmit}>
              <label>
                请选择：
                <select onChange={this.handleChange} value={this.state.value}>
                  <option value="one">选择一</option>
                  <option value="two">选择二</option>
                  <option value="three">选择三</option>
                </select>
              </label>
              <input type="submit" value="提交" />
            </form>
          );
        }
      }

      ReactDOM.render(<SelectFrom />, document.getElementById("root"));
    </script>
  </body>
</html>
